home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Small Eiffel 0.4.8 / lib_std / file_tools.e < prev    next >
Text File  |  1997-04-13  |  2KB  |  78 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. expanded class FILE_TOOLS
  5.  
  6. inherit ANY
  7.    redefine same_files
  8.       end;
  9.  
  10. feature
  11.  
  12.    same_files(path1, path2: STRING): BOOLEAN is
  13.      -- True if `path1' file exists and as the 
  14.      -- same contents as file `path2'.
  15.       require else
  16.      path1 /= Void;
  17.      path2 /= Void;
  18.       do
  19.      if file_exists(path1) then
  20.         if file_exists(path2) then
  21.            std_fr1.connect_to(path1);
  22.            if std_fr1.is_connected then
  23.           std_fr2.connect_to(path2);
  24.           if std_fr2.is_connected then
  25.              Result := std_fr1.same_as(std_fr2);
  26.           end;
  27.            else 
  28.           std_fr1.disconnect;
  29.            end;
  30.         end;
  31.      end;
  32.       end;
  33.  
  34.    is_readable(path: STRING): BOOLEAN is
  35.      -- True if `path' file exists and is a readable file.
  36.       do
  37.      std_fr1.connect_to(path);
  38.      Result := std_fr1.is_connected;
  39.      if Result then
  40.         std_fr1.disconnect;
  41.      end;
  42.       end;
  43.  
  44.    is_empty(path: STRING): BOOLEAN is
  45.      -- True if `path' file exists, is readable and is an 
  46.      -- empty file.
  47.       do
  48.      if file_exists(path) then
  49.         std_fr1.connect_to(path);
  50.         if std_fr1.is_connected then
  51.            std_fr1.read_character;
  52.            Result := std_fr1.end_of_input;
  53.            std_fr1.disconnect;
  54.         end;
  55.      end;
  56.       end;
  57.  
  58. feature {NONE}
  59.  
  60.    std_fr1: STD_FILE_READ is
  61.       once
  62.      !!Result.make;
  63.       end;
  64.  
  65.    std_fr2: STD_FILE_READ is
  66.       once
  67.      !!Result.make;
  68.       end;
  69.  
  70. feature {NONE}
  71.    
  72.    tmp_string: STRING is
  73.       once
  74.      !!Result.make(256);
  75.       end;
  76.  
  77. end -- FILE_TOOLS
  78.